<%@ page import="com.dbc.StudentsDB" %>
<%@ page import="java.util.List" %>
<%@ page import="com.vo.Students" %>
<%@ page import="java.util.Map" %>
<%@ page import="com.dbc.ClassesDB" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>学生列表</title>
    <link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>

<div class="container">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="page-header">
                <h1>
                    <small>学生列表--------显示所有学生</small>
                </h1>
            </div>
        </div>
        <div class="row">
            <div class="col-md-4 column">
                <a class="btn btn-primary" href="insertStudents.jsp">新增</a>
                <a class="btn btn-primary" href="showStudents_.jsp">显示全部</a>
            </div>
            <div class="col-md-8 column">
                <form class="form-inline" action="queryStudents.jsp" method="post" style="float: right">
                    <span style="color: red;font-weight: bold">
                        ${error}
                    </span>
                    <input type="text" name="queryBookName" class="form-control" placeholder="请输入查询名称">
                    <input type="submit" value="查询" class="btn btn-primary">
                </form>
            </div>
        </div>
    </div>

    <div class="row clearfix">
        <div class="col-md-12 column">
            <table class="table table-hover table-striped">
                <thead>
                <tr>
                    <th>学号</th>
                    <th>姓名</th>
                    <th>密码</th>
                    <th>班级</th>
                    <th>操作</th>
                </tr>
                </thead>

                <tbody>
                <%StudentsDB sdb = new StudentsDB();
                    List<Students> students = sdb.getAllStudents();
                    ClassesDB cdb = new ClassesDB();
                    Map<Integer,String> classesMap = cdb.getClassesMap();
                    for (Students stu:students) {%>
                <tr>
                    <td><%=stu.getStudentId()%></td>
                    <td><%=stu.getStudentName()%></td>
                    <td><%=stu.getStudentPwd()%></td>
                    <td><%=classesMap.get(stu.getClassId())%></td>
                    <td>
                        <a href="updateStudents.jsp?id=<%=stu.getStudentId()%>">更改</a> |
                        <a href="deleteStudents.jsp?id=<%=stu.getStudentId()%>">删除</a>
                    </td>
                </tr>
                <%}%>
                </tbody>
            </table>
        </div>
    </div>
</div>


</body>
</html>
